<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8">

<style>
img{
	display: block;
	width:400px;
	height:400px;
}


</style>

</head>
<body>

<img src="5.jpg" id="img1">

<script type="text/javascript">
//实现图片的切换
var imgs="1.jpg,2.jpg,3.jpg,4.jpg,5.jpg,6.jpg".split(",");
var index=0;
function next(){
		if(index==imgs.length-1){
		index=-1;
	}
	var str=document.getElementById("img1");
	str.src=imgs[++index];
	console.log(index);

}

function last(){
		if(index==0){
		index=imgs.length;
	}
	var str=document.getElementById("img1");
	str.src=imgs[--index];
	console.log(index);
}




</script>

<button onclick="last()">上一张</button>
<button onclick="next()">下一张</button>


</body>
</html>